import {
    View
} from 'react-native';

interface Rect {
    x: number,
    y: number,
    w: number,
    h: number,
    left: number,
    top: number
}

export default (el: View): Promise<Rect> => (
    new Promise(resolve => {
        if (!el || !el.measure) {
            resolve({
                x: 0, y: 0,
                w: 0, h: 0,
                left: 0, top: 0
            })
        }
        el.measure((
            x, y,
            w, h,
            left, top
        ) => (
            resolve({
                x, y,
                w, h,
                left, top
            })
        ))
    })
)